package cn.lili.controller.user.redpack;

import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.member.entity.dos.RedPackUser;
import cn.lili.modules.member.entity.dos.RedPackUserHistory;
import cn.lili.modules.member.service.RedPackUserHistoryService;
import cn.lili.modules.member.service.RedPackUserService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "红包广场用户接口")
@RequestMapping("/user/redPackUser")
@RequiredArgsConstructor
public class RedPackUserController {

    private final RedPackUserService redPackUserService;

    private final RedPackUserHistoryService redPackUserHistoryService;

    @ApiOperation(value = "分页获取红包任务用户数据")
    @GetMapping
    public ResultMessage<Page<RedPackUser>> getByPage(RedPackUser redPackUser, PageVO page) {
        return ResultUtil.data(redPackUserService.getByPage(redPackUser, page));
    }

    @ApiOperation(value = "修改用户状态")
    @GetMapping("/updateUserStatus/{id}")
    public ResultMessage<Void> updateUserStatus (@PathVariable String id, Integer status) {
        redPackUserService.updateUserStatus(id, status);
        return ResultUtil.success();
    }

    @ApiOperation(value = "分页获取用户红包变更记录")
    @GetMapping("/getUserHistoryByPage/{userId}")
    public ResultMessage<Page<RedPackUserHistory>> getUserHistoryByPage (@PathVariable String userId, PageVO pageVO) {
        return ResultUtil.data(redPackUserHistoryService.getByPage(userId, pageVO));
    }

    @ApiOperation(value = "用户是否实名认证")
    @GetMapping("/getIsCertification")
    public ResultMessage<Integer> getIsCertification () {
        return ResultUtil.data(redPackUserService.getIsCertification());
    }
}
